﻿namespace battlenet.wow.rt.domain.objects
{
    public class Price
    {
        public int Gold { get; set; }

        public int Silver { get; set; }
        
        public int Copper { get; set; }

        public Price(int gold, int silver, int copper)
        {
            Gold = gold;
            Silver = silver;
            Copper = copper;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Price"/> class. Uses battlenet api currency format (GGGGGSSCC);
        /// </summary>
        /// <param name="price">The price.</param>
        public Price(long price)
        {
            var priceStr = price.ToString();
            Copper = int.Parse(priceStr.Substring(priceStr.Length - 2, 2));
            Silver = int.Parse(priceStr.Substring(priceStr.Length - 4, 2));
            Gold = int.Parse(priceStr.Substring(0, priceStr.Length - 4));
        }
    }
}
